#include "VertexFormats.fx"
#include "Lighting.fx"

float4x4 world : WORLD;
float4x4 world_view_proj : WORLD_VIEW_PROJECTION;
float3 camera_pos : CAMERA_POS;

float3 light1_pos = {-2.0, 1.0, -6.0};
float3 light1_color = {0.3, 0.2, 0.7};
float light1_attenuation;

float3 light2_pos = {2.0, -1.0, 10.0};
float3 light2_color = {1.0, 0.07, 0.05};
float light2_attenuation;

struct VSOut
{
	float4 pos : POSITION;
	float3 normal : TEXCOORD0;
	float3 world_pos : TEXCOORD1;
};

VSOut VS_Crystal(VertexPosNormal input)
{
	VSOut output;
	output.pos = mul(float4(input.pos, 1), world_view_proj);
	output.normal = mul(float4(input.normal, 0), world);
	output.world_pos = mul(float4(input.pos, 1), world);
	return output;
}

float4 PS_Crystal(VSOut input) : COLOR
{
	float3 n = normalize(input.normal);
	float3 lights = pointLight(input.world_pos, n, light1_pos,
		light1_color, float3(0, 0, light1_attenuation));
	lights += pointLight(input.world_pos, n, light2_pos,
		light2_color, float3(0, 0, light2_attenuation));
	return float4(lights, 1);
}

technique t0
{
	pass p0
	{
		VertexShader = compile vs_2_0 VS_Crystal();
		PixelShader = compile ps_2_0 PS_Crystal();

		AlphaBlendEnable = false;
		ZEnable = true;
		CullMode = CCW;
	}
}

